<%@page import="com.baoyanghui.common.Constants"%>
<%@page import="com.baoyanghui.common.Utils"%>
<%@page import="com.baoyanghui.model.MerchantPlace"%>
<%@page import="com.baoyanghui.model.ItemType"%>
<%@page import="com.baoyanghui.config.Configs"%>
<%@page import="com.baoyanghui.common.DataChanger"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.HashMap"%>
<%@page import="com.baoyanghui.model.ItemShortcut"%>
<%@page import="java.util.List"%>
<%@page import="net.sf.json.JSONObject"%>
<%@page import="com.baoyanghui.common.InterfaceAccess"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%
	if (Utils.empty((String)request.getSession().getAttribute(Configs.SESSION_USER_ID))
			|| (Constants.USER_TYPE_CUSTOMER == (Integer)request.getSession().getAttribute(Configs.SESSION_USER_TYPE))) {
		response.getWriter().print("<script type='text/javascript'>\n");
		response.getWriter().print("window.location.href='" + request.getContextPath() + "/index.jsp';\n");
		response.getWriter().print("</script>\n");
		response.getWriter().flush();
		return;
	}
%>
<%
	JSONObject shortcuts = null;
	ItemShortcut shortcut = null;
	List<ItemShortcut> shortcutList = null;
	JSONObject itemTypes = null;
	ItemType type = null;
	List<ItemType> typeList = null;
	Map<String, String> params = new HashMap<String, String>();
	JSONObject places = null;
	MerchantPlace place = null;
	List<MerchantPlace> placeList = null;
	
	try {
		request.setCharacterEncoding("UTF-8");
		params.put("merchant_id", (String)session.getAttribute(Configs.SESSION_USER_ID));
		params.put("usercode", (String)session.getAttribute(Configs.SESSION_USERCODE));
		
		shortcuts = InterfaceAccess.callInterface("/merchant/get_item_shortcut", params);
		shortcutList = DataChanger.getItemShortcuts(shortcuts);
		places = InterfaceAccess.callInterface("/merchant/get_places", params);
		placeList = DataChanger.getPlaces(places);
		
		params.clear();
		params.put("parent_id", "0");
		
		itemTypes = InterfaceAccess.callInterface("/get_item_type", params);
		typeList = DataChanger.getItemTypes(itemTypes);
	} catch (Exception e) {
		return;
	}
%>
<script type="text/javascript" src="../js/json2.js"></script>
<script type="text/javascript" src="../js/add_maintain_order.js"></script>
<div style="border-bottom: 1px #999999 solid; padding-top: 10px;">
	<img class="pointer fade_effect" src="<%= request.getContextPath() %>/image/menu_user_info_off.png" 
		style="margin-left: 18px; float: left;" onclick="showUserInfo(selectedCusutomerIndex);"/>
	<img src="<%= request.getContextPath() %>/image/menu_maintain_info.png" style="float: left;"/>
	<div style="clear: both;"></div>
</div>
<h2 style="margin-left: 15px; margin-top: 20px;">基本信息</h2>
<form>
	<div style="width: 430px; float: left; margin-left: 80px; line-height: 50px;vertical-align: top;">
		<label>*本次保养里程：</label><input type="text" id="mileage" onblur="checkMileage();"/><br/>
		<label>*维修店地址：</label><select id="place_id" onblur="checkPlaceId();">
			<option value="">请选择维修店</option>
<%
	for (int i = 0; i < placeList.size(); i++) {
		place = placeList.get(i);
%>
			<option value="<%= place.getId() %>"><%= place.getAddress() %></option>
<%
	}
%>
		</select><br/>
		<label>备注：</label><input type="text" id="comment" maxlength="250"/><br/>
	</div>
	<div style="width: 430px; float: left; padding-left: 30px; line-height: 50px;">
		<label>计划保养日期：</label><input id="maintain_date" class="Wdate" type="text" onclick="WdatePicker()"/><br/>
		<label>*总计养护费用：</label><input type="text" id="total_fee" onblur="checkTotalFee();"/><br/>
		<label>状态：</label><input type="text" id="status" disabled="disabled" value="等待养护"/><br/>
	</div>
	<div style="clear:both;"></div>
</form>
<!-- 分隔线 -->
<div style="margin: 0px 5px; border-bottom: 1px dashed gray;"></div>
<h2 style="margin-left: 15px; margin-top: 20px;">养护信息</h2>
<form style="margin-left: 15px;">
	<div>
		<img class="col_title" src="<%= request.getContextPath() %>/image/col_maintain_item.png" alt="" />
		<img class="col_title" src="<%= request.getContextPath() %>/image/col_item_brand.png" alt="" />
		<img class="col_title" src="<%= request.getContextPath() %>/image/col_item_type.png" alt="" />
		<img class="col_title" src="<%= request.getContextPath() %>/image/col_item_cycle.png" alt="" />
		<div style="clear: both;"></div>
	</div>
	<div id="div_maintain_item_list">
	</div>
	<div style="padding-top: 2px">
		<div class="col_maintain_item"></div>
		<div class="col_item_brand"></div>
		<div class="col_item_type"></div>
		<div class="col_item_cycle"></div>
		<div style="clear: both;"></div>
	</div>
	<img class="pointer fade_effect" src="<%= request.getContextPath() %>/image/btn_add_new_item.png" style="margin: 15px 0px;" onclick="toggleAddItemDiv();"/>
</form>
<div id="div_add_new_item" style="margin: 0px 15px; margin-top: 7px; padding-top: 18px; background: #eae5d9; cursor: default; display: none;">
	<h2 style="margin-left: 15px;">快捷添加：<a class="blue" style="font-size: 13pt;">编辑快捷添加</a></h2>
	<div id="div_shortcuts"></div>
	<div style="margin: 0px 5px; border-bottom: 1px dashed gray;"></div>
	<h2 style="margin-left: 15px; margin-top: 18px;">手动添加：</h2>
	<div>
		<div id="div_move_left" style="width: 45px; height: 160px; float: left; background: url(../image/btn_move_left.png)"
			class="pointer fade_effect" onclick="moveLeft();"></div>
		<div id="div_scroll_bar" style="width: 808px; margin-left: 15px; float: left; overflow-x: hidden; overflow-y: hidden;">
			<div id="div_scroll" style="width: 500px;">
				<div class="1" style="float: left; width: 200px; height: 160px; overflow-y: scroll; background: white; border: inset 1px gray;">
<%
	for (int i = 0; typeList != null && i < typeList.size(); i++) {
		type = typeList.get(i);
%>
					<div style="background: url('../image/right_arrow.png') right no-repeat;">
						<div class="option" onclick="selectOption(this, '<%= type.getTypeId() %>');"><%= type.getTypeName() %></div>
					</div>
<%
	}
%>
				</div>
				<div style="clear: both;"></div>
			</div>
		</div>
		<div id="div_move_right" style="width: 45px; height: 160px; float: left; background: url(../image/btn_move_right.png)"
			class="pointer fade_effect" onclick="moveRight();"></div>
		<div style="clear: both;"></div>
	</div>
	<div style="padding: 15px;">
		<img class="pointer fade_effect" src="<%= request.getContextPath() %>/image/btn_save_new_item.png" onclick="saveNewItem();" align="top"/>
		<a class="blue" style="font-size: 13pt; display: inline-block; padding-top: 10px;" href="javascript: toggleAddItemDiv();">取消</a>
	</div>
</div>
<!-- 分隔线 -->
<div style="margin: 0px 5px; border-bottom: 1px dashed gray;"></div>
<div align="center" style="margin-top: 50px; padding-bottom: 75px;">
	<img class="pointer fade_effect" alt="" src="../image/btn_complete.png" onclick="addMaintainOrder();">
	<img class="pointer fade_effect" alt="" src="../image/btn_cancel.png" style="margin-left: 40px;" onclick="showMaintainHistory();">
</div>